{extend name="public:base"/}


{block name="title"}新增广告{/block}
{block name="style"}
<link href="__STATIC__/admin/plugin/my_uploader/css/uploads.css" rel="stylesheet">
{/block}

{block name="main"}

<section class="content" xmlns="http://www.w3.org/1999/html">
    <div class="row">

        <div class="col-md-12">

            <div class="row">
                <div class="col-lg-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">新增广告</h3>
                        </div>
                        <form  id="pt_form" method="post">
                            <div class="box-body">

                                <div class="clearfix"></div>

     
                                <div class="form-group required">
                                    <div class='col-sm-2 text-right'>
                                        <label for="adv_title" class="control-label Validform_label" >广告名称</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="text" id="adv_title" class="form-control" name="adv_title" placeholder="请输入广告名称" datatype="s2-255" ignore="ignore"  errormsg="广告名称超出长度范围">
                                        <div class="help-block"></div>
                                    </div>
                                </div>
          
                                <div class="form-group required">
                                    <div class='col-sm-2 text-right'>
                                        <label class="control-label" for="ap_id">广告位id</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <select id="ap_id" class="form-control" name="ap_id">
                                            <?php if(!empty($position)){ foreach($position as $k=>$v){?>
                                            <option value="<?=$v['id']?>"><?=$v['ap_name']?></option>
                                            <?php }}?>
                                        </select>
                                        <div class="help-block"></div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class='col-sm-2 text-right'>
                                        <label for="ap_width" class="control-label Validform_label" >广告图片</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <div class="test">
                                            <div class="up-button" id="select-img">选择图片</div>
                                            <div class="img-list" id="img-list">
                                                <!--图片列表样例-->
                                                <div class="img-item">
                                                    <img src="__STATIC__/admin/plugin/my_uploader/images/defalut.jpg">
                                                    <em class="delete" onclick="uploader.del_list(this)">×</em>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>


                                <div class="form-group ">
                                    <div class='col-sm-2 text-right'>
                                        <label for="adv_url" class="control-label Validform_label" >链接地址</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="text" id="adv_url" class="form-control" name="adv_url" placeholder="请输入链接地址" datatype="url" ignore="ignore"  errormsg="链接地址格式不正确">
                                        <div class="help-block"></div>
                                    </div>
                                </div>
               
                                <div class="form-group ">
                                    <div class='col-sm-2 text-right'>
                                        <label for="slide_sort" class="control-label Validform_label" >排序</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="text" id="slide_sort" class="form-control" name="slide_sort" placeholder="请输入幻灯片排序" datatype="n" value="0" ignore="ignore"  errormsg="排序是数字类型">
                                        <div class="help-block"></div>
                                    </div>
                                </div>
                                 </div>
                            <div class="box-footer text-center">
                                <button class="btn btn-primary" type="submit">保存</button>
                                <span class="btn btn-white" onclick="history.go(-1)">返回</span>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
{/block}

{block name="js"}
<script src="__STATIC__/admin/plugin/my_uploader/js/uploads.js"></script>
<script>

    var validate = validator('#pt_form');
    $('#select-img').click(function(){
        uploader.open({
            elm:'select-img',//选择图片上传的按钮
            url:"<?=url('common/AjaxController/uploader',['path'=>'adv'])?>",//服务器url
            up_type:1,//上传图片类型1:单图,2:多图
            img_list:'img-list',//存放选择图片之后的容器
            input_name:'adv_image',//上传图片表单ID
            img_num:6,//多图上传的总数
            num:2
        });
    });

</script>
{/block}